package com.tij.rtti.typeinfo;

/**
 * @ClassName:Sweet Shop
 * @author:
 * @Description: Examination of the way the class loader works
 * data:2024/10/6 18:38
 * @since
 **/
class Candy{
    static {
        System.out.println("static --- Candy");
    }
}
class Gum{
    static {
        System.out.println("Static --- Gum");
    }
}

class Cookie{
    static {
        System.out.println("Static --- Cookie");
    }
}

public class SweetShop {
    public static void main(String[] args) {
        System.out.println("inside ---- main");
        //new Candy();
        //System.out.println(" ---- After new Candy() ...");

        try {
//            Class.forName("Gum");  // exception ClassNotFoundException
            Class.forName("com.tij.rtti.typeinfo.Gum");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        System.out.println(" ---- after Class.forName(\"Gum\")");

        //new Cookie();

        System.out.println(" ---- new Cookie()");

        String className = null;
        if(args.length>0){
            className = args[0];
        }
        try {
            System.out.println();
            Class.forName("com.tij.rtti.typeinfo."+className);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
